<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>日志查询-科长审批</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <link rel="stylesheet" href="/css/custom.form.css">
    <style type="text/css">
        .layui-disabled, .layui-disabled:hover {
            color: #000000 !important;
            cursor: not-allowed !important;
        }

        .layui-form-label {
            width: 100px;
        }

        .layui-input-block {
            margin-left: 130px;
        }

        .layui-input layui-unselect {
            cursor: pointer;
        }

        .layui-table {
            width: 96%;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <div class="panel panel-default operation" hidden>
                        <div class="panel-heading title"></div>
                        <div class="layui-tab">
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-card-body">
                                        <form class="layui-form" action="" lay-filter="info">
                                            <input name="_tabKey" id="_tabKey" hidden>
                                            <input name="_jcajxxuuid" id="_jcajxxuuid" hidden>
                                            <div class="layui-form-item">
                                                <label class="layui-form-label">填报时间</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" readonly class="layui-input" id="contentdate"
                                                           placeholder="请输入填报日期">
                                                </div>
                                                <div id="moldDiv">
                                                    <label class="layui-form-label">填报类型</label>
                                                    <div class="layui-input-inline">
                                                        <select lay-search="" name="mold" lay-filter="mold" id="mold">
                                                            <option value="">请选择填报类型</option>
                                                        </select>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="inspectionHearInfo">
                                                <fieldset class="layui-elem-field layui-field-title"
                                                          style="margin-top: 10px;">
                                                    <legend id="jcajbh"></legend>
                                                </fieldset>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">企业名称</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="ajmc" name="ajmc"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>

                                                    <label class="layui-form-label">检查项目</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="jcxm" name="jcxm"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">检查人</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="jcry" name="jcry"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>
                                                <div class="layui-form-item">
                                                    <label class="layui-form-label">纳税人名称</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="nsrmc" name="nsrmc"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                    <label class="layui-form-label">纳税人识别号</label>
                                                    <div class="layui-input-inline">
                                                        <input type="text" id="nsrsbh" name="nsrsbh"
                                                               class="layui-input layui-disabled" disabled="ture">
                                                    </div>
                                                </div>
                                            </div>
                                            <fieldset class="layui-elem-field layui-field-title"
                                                      style="margin-top: 10px;">
                                                <legend>完成工作</legend>
                                            </fieldset>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
									<textarea rows="2" name="content1" id="content1"
                                              placeholder="请输入反馈信息,1-500个字符" autocomplete="off"
                                              class="layui-textarea"
                                              onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
                                                    <span class="red" id="textarea_length1">0</span> / <span
                                                        class="num_count1">500</span>
                                                </div>
                                            </div>
                                            <div id="content2and3Div">
                                                <fieldset class="layui-elem-field layui-field-title"
                                                          style="margin-top: 10px;">
                                                    <legend>发现问题</legend>
                                                </fieldset>
                                                <div class="layui-form-item">
                                                    <div class="layui-input-block">
										<textarea rows="2" name="content2" id="content2"
                                                  placeholder="请输入,1-500个字符" autocomplete="off"
                                                  class="layui-textarea"
                                                  onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
                                                        <span class="red" id="textarea_length1">0</span> / <span
                                                            class="num_count1">500</span>
                                                    </div>
                                                </div>
                                                <fieldset class="layui-elem-field layui-field-title"
                                                          style="margin-top: 10px;">
                                                    <legend>下步打算</legend>
                                                </fieldset>
                                                <div class="layui-form-item">
                                                    <div class="layui-input-block">
										<textarea rows="3" name="content3" id="content3"
                                                  placeholder="请输入,1-500个字符" autocomplete="off"
                                                  class="layui-textarea"
                                                  onkeyup="javascript:texLength1(this, 'textarea_length1');"></textarea>
                                                        <span class="red" id="textarea_length1">0</span> / <span
                                                            class="num_count1">500</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <fieldset class="layui-elem-field layui-field-title" id="bottomLine"
                                                      style="margin-top: 10px;"></fieldset>
                                            <div class="layui-form-item">
                                                <div class="layui-input-block">
                                                    <button type="submit" class="layui-btn" id="saveWorkflowLog"
                                                            onclick="return false" lay-submit
                                                            lay-filter="saveWorkflowLog">提交
                                                    </button>
                                                    <button class="layui-btn layui-btn-primary" id="btn_cancel">返回
                                                    </button>
                                                </div>
                                            </div>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div">
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item" style="margin-left: 10px">
                                    <div class="layui-input-inline">
                                        <input type="text" readonly class="layui-input" id="createTime"
                                               placeholder="创建时间">
                                    </div>
                                    <div class="layui-input-inline layui-form">
                                        <select id="logType">
                                            <option value="">日志类型</option>
                                            <option value="1">日常日志</option>
                                            <option value="2">案件日志</option>
                                        </select>
                                    </div>
                                    <div class="layui-input-inline ">
                                        <button class="layui-btn" onclick="searchLog()" id="search">查询</button>
                                    </div>
                                </div>
                                <table class="layui-table" id="logShowTable" lay-filter="logShowTable"></table>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab table_div1" hidden>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <div class="layui-form-item"></div>
                                <table class="layui-table" id="showTable" lay-filter="showTable"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script type="text/html" id="logToolbar"></script>
<script type="text/html" id="toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="cancel">返回</button>
    </div>
</script>
<script type="text/html" id="tool">
    <a class="layui-btn layui-btn-xs" lay-event="addinspectionhear">填写日志</a>
</script>
<script src="/layui/layui.all.js"></script>
<script src="/js/core.util.js"></script>
<script th:inline="none">
    // 获取token
    var token = CoreUtil.getData("access_token");
    // 地址栏转义token中的#号
    var tokenQuery = token.replace("#", "%23");
    var logShowTable;
    var showTable;
    var table = layui.table;
    var form = layui.form;
    var layer = layui.layer;
    var $ = jQuery = layui.jquery;
    var laydate = layui.laydate;
    var upload = layui.upload;
    var element = layui.element;
    var maxlength = 500;
    var inspectionMan = "";
    var mold = "";
    var contentdate = null;
    var startTime = null;
    var endTime = null;
    $(document).ready(function () {
        var myDate = new Date;
        var year = myDate.getFullYear(); //获取当前年
        var mon = myDate.getMonth() + 1; //获取当前月
        var date = myDate.getDate(); //获取当前日
        var h = myDate.getHours();//获取当前小时数(0-23)
        var m = myDate.getMinutes();//获取当前分钟数(0-59)
        var s = myDate.getSeconds();//获取当前秒
        contentdate = year + "-" + mon + "-" + date + " 00:00:00";
        $("#contentdate").val(contentdate)
    })
    layui.use(['table', 'layer', 'laydate', 'upload', 'element'], function () {
        form.on('select(mold)', function () {
            var myselect = document.getElementById("mold");
            var index = myselect.selectedIndex; // selectedIndex代表的是你所选中项的index
            mold = myselect.options[index].value;
        });
        laydate.render({
            elem: '#createTime'
            , type: 'datetime'
            , range: '~'
            , done: function (value, date, endDate) {
                if (value != null && value != undefined && value != "") {
                    startTime = value.split("~")[0];
                    endTime = value.split("~")[1];
                } else {
                    startTime = null;
                    endTime = null;
                }

            }
        });
        var mapArr = {
            'dictId': "1712894076144693250",
        };
        CoreUtil.sendPost("/sysDictDetail/list", mapArr, function (res) {
            if (res.code === 0) {
                var value = res.data;
                var opt = "<option value = ''>请选择填报类型</option>";
                for (var i in value) {
                    opt += '<option value = "' + value[i].value + '">' + value[i].label + '</option>';
                }
                $("#mold").html(opt);
                form.render('select'); //需要渲染一下
            } else {
                layer.msg(res.msg);
                return false;
            }
        });
        //日期范围
        laydate.render({
            elem: '#contentdate'
            , type: 'datetime'
            , done: function (value, date, endDate) {
                if (value !== null && value !== undefined && value !== "") {
                    contentdate = value.split("~")[0];
                } else {
                    //清空时间的时候要清空以前选择的日期
                    contentdate = null;
                }
            }
        });
        // 受理人列表
        showTable = table.render({
            elem: '#showTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/activity/list' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },
            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'jcajxxuuid',
                    title: '检查UUID',
                    sort: true,
                    hide: true
                }, {
                    fixed: 'right',
                    align: 'center',
                    width: 95,
                    toolbar: "#tool",
                    title: '操作'
                }, {
                    align: 'center',
                    width: 158,
                    field: 'jcajbh',
                    title: '检查案件编号',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'ajmc',
                    title: '企业名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'stateName',
                    title: '系统状态',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'jcry',
                    title: '检查人员',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'jcxm',
                    title: '检查项目',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'nsrmc',
                    title: '纳税人名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'nsrsbh',
                    title: '纳税人识别号',
                    sort: true,
                }
            ]],
            toolbar: '#toolbar'
        });
        // 列操作
        table.on('tool(showTable)', function (obj) {
            var data = obj.data;
            switch (obj.event) {
                case 'addinspectionhear':
                    addinspectionhear("1", data);
                    break;
            }
        });
        // 个人待办表头工具
        table.on('toolbar(showTable)', function (obj) {
            switch (obj.event) {
                case 'cancel':
                    back();
                    break;
            }
        });

        // 工作日志
        logShowTable = table.render({
            elem: '#logShowTable',
            contentType: 'application/json',
            headers: {
                "authorization": token
            },
            page: true // 开启分页
            ,
            url: '/workflow/log/querylist' //数据接口
            ,
            method: 'POST',
            parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": CoreUtil.isEmpty(res.data) ? 0 : res.data.total, //解析数据长度
                    "data": CoreUtil.isEmpty(res.data) ? null
                        : CoreUtil.paramsDecrypt(res.data.records)
                }
            },

            cols: [[
                {
                    align: 'center',
                    width: 230,
                    field: 'id',
                    title: '日志编号',
                    sort: true,
                    hide: true
                }, {
                    align: 'center',
                    width: 168,
                    field: 'createId',
                    title: '填写人',
                    sort: true,
                }, {
                    align: 'center',
                    width: 158,
                    field: 'type',
                    title: '日志类型',
                    sort: true,
                    templet: function (item) {
                        if (item.type == "1") {
                            return "日常日志";
                        } else if (item.type == "2") {
                            return "案件日志";
                        } else {
                            return "未知：" + item.type;
                        }
                    }
                }, {
                    align: 'center',
                    width: 158,
                    field: 'contentdate',
                    title: '日志日期',
                    sort: true, templet: function (d) {
                        if (!d.contentdate) {
                            return '';
                        }
                        return layui.util.toDateString(d.contentdate, 'yyyy-MM-dd');
                    }
                }, {
                    align: 'center',
                    width: 218,
                    field: 'content1',
                    title: '完成工作',
                    sort: true,
                }, {
                    align: 'center',
                    width: 218,
                    field: 'sectionchiefContent',
                    title: '科长审批',
                    templet: function (item) {
                        if (item.sectionchiefContent == "") {
                            return "未审批内容";
                        } else {
                            return item.sectionchiefContent;
                        }
                    },
                    sort: true,
                }, {
                    align: 'center',
                    width: 150,
                    field: 'disciplineContent',
                    title: '纪检审批内容',
                    templet: function (item) {
                        if (item.disciplineContent == "") {
                            return "未审批";
                        } else {
                            return item.disciplineContent;
                        }
                    },
                    sort: true,
                }, {
                    align: 'center',
                    width: 240,
                    field: 'ajmc',
                    title: '企业名称',
                    sort: true,
                }, {
                    align: 'center',
                    width: 168,
                    field: 'ajbh',
                    title: '案件编号',
                    sort: true,
                }
            ]],
            toolbar: '#logToolbar'
        });

        // 个人待办表头工具
        table.on('toolbar(logShowTable)', function (obj) {
            switch (obj.event) {
                case 'addinspectionhear':
                    addinspectionhear("0");
                    break;
                case 'add':
                    add();
                    break;
            }
        });

        // 返回
        $("#btn_cancel").click(function () {
            back();
            return false;
        });
        form.on('submit(saveWorkflowLog)', function (data) {
            var content1 = $("#content1").val();
            if (CoreUtil.isEmpty(content1)) {
                layer.msg("【完成工作】内容未填写！");
                return false;
            }
            if (CoreUtil.isEmpty(contentdate)) {
                layer.msg("填报时间未填写！");
                return false;
            }
            var content2 = $("#content2").val();
            var content3 = $("#content3").val();
            var _tabKey = $("#_tabKey").val();
            var url = "";
            if (_tabKey == "add") {
                url = "/workflow/log/add";
            } else if (_tabKey == "addinspectionhear") {
                if (CoreUtil.isEmpty(mold)) {
                    layer.msg("填报类型未填写！");
                    return false;
                }
                if (CoreUtil.isEmpty(content2)) {
                    layer.msg("【发现问题】内容未填写！");
                    return false;
                }
                if (CoreUtil.isEmpty(content3)) {
                    layer.msg("【下步打算】内容未填写！");
                    return false;
                }
                url = "/workflow/log/addinspectionhear";
            } else {
                layer.msg("_tabKey不正确！" + _tabKey);
                return false;
            }
            var mapArr = {
                content1: content1,
                content2: content2,
                content3: content3,
                mold: mold,
                contentdate: contentdate,
                relevance: $("#_jcajxxuuid").val(),
            };

            CoreUtil.sendPost(url, mapArr, function (res) {
                if (res.code === 0) {
                    layer.msg("日志填报成功！");
                    back();
                } else {
                    layer.msg(res.msg);
                    return false;
                }
            });

        });
    });

    function search() {
        showTable.reload({
            where: {},
            page: {
                curr: 1
            }
        });
    };

    function searchLog() {
        logShowTable.reload({
            where: {
                type: $("#logType").val(),
                startTime: startTime,
                endTime: endTime,
            },
            page: {
                curr: 1
            }
        });
    }

    function texLength1(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('反馈内容字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    }

    function texLength2(obj, id) {
        var curr = obj.value.length;
        if (curr > maxlength) {
            layer.msg('推送原因字数在' + maxlength + '字以内');
        } else {
            document.getElementById(id).innerHTML = curr;
        }
    };

    function add() {
        $("#_tabKey").val("add");
        $("#content2and3Div").hide();
        $("#inspectionHearInfo").hide();
        $(".table_div").hide();
        $(".table_div1").hide();
        $(".operation").show();
        $("#moldDiv").hide();
    }

    function addinspectionhear(id, data) {
        $("#_tabKey").val("addinspectionhear");
        $("#moldDiv").show();
        if (id == "0") {
            $("#inspectionHearInfo").hide();
            $(".table_div1").show();
            $(".table_div").hide();
            $(".operation").hide();
        } else if (id == "1") {
            $("#content2and3Div").show();
            $("#jcajbh").html("案件编号：" + data.jcajbh);
            $("#_jcajxxuuid").val(data.jcajxxuuid);
            $("#ajmc").val(data.ajmc);
            $("#jcxm").val(data.jcxm);
            $("#nsrmc").val(data.nsrmc);
            $("#nsrsbh").val(data.nsrsbh);
            $("#jcry").val(data.jcry);
            $("#inspectionHearInfo").show();
            $(".table_div1").hide();
            $(".table_div").hide();
            $(".operation").show();
        }
    }

    function back() {
        search();
        searchLog();
        $("#inspectionHearInfo").hide();
        $(".table_div1").hide();
        $(".table_div").show();
        $(".operation").hide();
    }

</script>

</body>
</html>
